#include "checkvaluecontainer.h"
#include "common/floatcompara.h"

CheckValueContainer::CheckValueContainer(QObject* parent):QObject(parent),mToHiCnt(0),mToOkCnt(0),mToLoCnt(0),
    mToHiWgt(0),mToLoWgt(0),mToOkWgt(0),mHiAve(0),mOkAve(0),mLoAve(0),mHiMax(0),mOkMax(0),mLoMax(0),mHiMin(0),
    mOkMin(0),mLoMin(0)
{

}

void CheckValueContainer::init()
{
    mToHiCnt=0;mToOkCnt=0;mToLoCnt=0;
    mToHiWgt=0;mToLoWgt=0;mToOkWgt=0;
    mHiAve=0;mOkAve=0;mLoAve=0;
    mHiMax=0;mOkMax=0;mLoMax=0;
    mHiMin=0;mOkMin=0;mLoMin=0;
}

void CheckValueContainer::calLoValues(float net)
{
    mToLoWgt += net;
    mToLoCnt ++;
    if(F_BZ(net-mLoMax))
    {
        mLoMax = net;
    }
    if(F_SZ(net-mLoMin)||F_EZ(mLoMin))
    {
        mLoMin = net;
    }
    mLoAve = mToLoWgt/mToLoCnt;
}

void CheckValueContainer::calOkValues(float net)
{
    mToOkWgt += net;
    mToOkCnt ++;
    if(net>mOkMax)
    {
        mOkMax = net;
    }
    if(net<mOkMin)
    {
        mOkMin = net;
    }
    mOkAve = mToOkWgt/mToOkCnt;
}

void CheckValueContainer::calHiValues(float net)
{
    mToHiWgt += net;
    mToHiCnt ++;
    if(net>mHiMax)
    {
        mHiMax = net;
    }
    if(net<mHiMin)
    {
        mHiMin = net;
    }
    mHiAve = mToHiWgt/mToHiCnt;
}

